#include "test_byte.h"
#include "string.h"
#include "stdlib.h"
#include "esp_system.h"


static int lua_free_heap(lua_State *L){
    uint32_t heap=esp_get_free_heap_size();
    lua_pushinteger(L,heap);
    
    return 1;
}


static int lua_minimum_free_heap(lua_State *L){
    uint32_t heap=esp_get_minimum_free_heap_size();
    lua_pushinteger(L,heap);
    return 1;
}

static const luaL_Reg memfunc[] ={
    {"freeHeap", lua_free_heap},
    {"minimumFree", lua_minimum_free_heap},
	{NULL, NULL}
};



//下面两个直接注册成模块
LUAMOD_API int luaopen_memlibs(lua_State *L) {
  luaL_newlib(L, memfunc);
  return 1;
}
